DNS Management for Servers Lab
1. Configure unbound as a Caching Nameserver
In this lab, you configure unbound as a caching nameserver and administer its cache data.
You were asked to improve name resolution performance and enhance DNS security in your company’s datacenter. You decided to deploy a caching nameserver using an unbound DNS server. You want to configure unbound to respond only to queries on the datacenter subnet,
192.168.0.0/24. You also want to forward recursive queries to the company’s main internal DNS server at 192.168.0.254. This main internal DNS
server hosts an internal, split DNS copy of the company’s example.com zone. This example.com zone is not DNSSEC-signed, so it must be exempt from DNSSEC validation on your caching nameserver. After configuring the caching nameserver on server1.example.com, you test it by querying for the host names desktop1.example.com and
server1.example.com from desktop1.example.com. Verify that the queries are populated
into the nameserver’s cache. Lastly, you purge server1.example.com from the cache.
Reset the
server1.example.comsystem.Log in to the
server1.example.comswitch to root usingsudo -i.Install the unbound package on
server1.example.com.[root@server1 ~]# yum install -y unbound
Enable and start the
unboundservice.[root@server1 ~]# systemctl enable unbound.service ln -s '/usr/lib/systemd/system/unbound.service' '/etc/systemd/system/multi-user.target.wants/unbound.service' [root@server1 ~]# systemctl start unbound.service
Configure
unboundto allow queries from the192.168.0.0/24subnet, exempt theexample.comzone from DNSSEC validation, and forward all queries to192.168.0.254.By default,
unboundlistens on the loopback interface. Configureunboundto listen on the 192.168.0.101 interface onserver1.example.comby adding the following option in theserverclause of/etc/unbound/unbound.conf.interface: 192.168.0.101
Allow queries from the
192.168.0.0/24subnet by adding the following option in theserverclause of/etc/unbound/unbound.conf.access-control: 192.168.0.0/24 allow
Exempt the
example.comzone from DNSSEC validation by adding the following option in theserverclause of/etc/unbound/unbound.conf.domain-insecure: "example.com"
Forward all queries to
192.168.0.254by adding aforward-zoneclause to the end of the/etc/unbound/unbound.conffile.forward-zone: name: . forward-addr: 192.168.0.254
Check
/etc/unbound/unbound.conffor syntax errors.[root@server1 ~]# unbound-checkconf unbound-checkconf: no errors in /etc/unbound/unbound.conf
Restart the
unboundservice.[root@server1 ~]# systemctl restart unbound.service
Configure the firewall to allow DNS traffic.
[root@server1 ~]# firewall-cmd --permanent --add-service=dns success [root@server1 ~]# firewall-cmd --reload success
Verify the caching name service by performing queries and examining the contents of the cache.
Dump the cache to see its contents.
[root@server1 ~]# unbound-control dump_cache START_RRSET_CACHE END_RRSET_CACHE START_MSG_CACHE END_MSG_CACHE EOFFrom
desktop1.example.com, queryserver1.example.comfor theArecord of host namedesktop1.example.com.[student@desktop1 ~]$ dig @server1.example.com A desktop1.example.com ... desktop1.example.com. 86349 IN A 192.168.0.1 ...
From
desktop1.example.com, queryserver1.example.comfor theArecord of host nameserver1.example.com.[student@desktop1 ~]$ dig @server1.example.com A server1.example.com ... server1.example.com. 86364 IN A 192.168.0.101 ...
On
server1.example.com, dump out the cache again. You should see the queried records in the cache.[root@server1 ~]# unbound-control dump_cache START_RRSET_CACHE ;rrset 85886 1 0 8 3 server1.example.com. 85886 IN A 192.168.0.101 ;rrset 85878 1 0 8 X desktop1.example.com. 85878 IN A 192.168.0.1 ;rrset 85878 1 0 7 3 example.com. 85878 IN NS instructor.example.com. ;rrset 85878 1 0 3 3 instructor.example.com. 85878 IN A 192.168.0.254 END_RRSET_CACHE START_MSG_CACHE msg desktop1.example.com. IN A 33152 1 85878 3 1 1 1 desktop1.example.com. IN A 0 example.com. IN NS 0 instructor.example.com. IN A 0 msg server1.example.com. IN A 33152 1 85886 3 1 1 1 server1.example.com. IN A 0 example.com. IN NS 0 instructor.example.com. IN A 0 END_MSG_CACHE EOF
Purge the
server1.example.comrecord from the cache.[root@server1 ~]# unbound-control flush server1.example.com ok
On
server1.example.com, dump out the cache again. You should no longer see theArecord forserver1.example.comin the cache.[root@server1 ~]# unbound-control dump_cache START_RRSET_CACHE ;rrset 85878 1 0 8 X desktop1.example.com. 85878 IN A 192.168.0.1 ;rrset 85878 1 0 7 3 example.com. 85878 IN NS instructor.example.com. ;rrset 85878 1 0 3 3 instructor.example.com. 85878 IN A 192.168.0.254 END_RRSET_CACHE START_MSG_CACHE msg desktop1.example.com. IN A 33152 1 85878 3 1 1 1 desktop1.example.com. IN A 0 example.com. IN NS 0 instructor.example.com. IN A 0 msg server1.example.com. IN A 33152 1 85886 3 1 1 1 server1.example.com. IN A 0 example.com. IN NS 0 instructor.example.com. IN A 0 END_MSG_CACHE EOF
2. Troubleshoot DNS
In this lab, you troubleshoot and resolve a name resolution issue by systematically verifying name service configurations to pinpoint the cause.
A user reports that there is an issue occurring when an SSH session is initiated to example.com from server1.example.com and a
"Could not resolve hostname example.com: Name or service not known" error is being generated. Therefore, the user complains that there is a problem with DNS name resolution of example.com. Like all other hosts on the network, server1.example.com should be using 192.168.0.254 for DNS resolution.
You need to troubleshoot the issue, identify the root cause, apply a fix, and then verify that the problem is resolved.
You cannot actually log in to |
Reset the
server1.example.comsystem.Log in to and set up the
server1.example.comsystem.[student@server1 ~]$ wget -O - http://instructor.example.com/pub/server1-dns.sh | bash
Replicate the reported issue by attempting an SSH session to
example.comfromserver1.example.com.[student@server1 ~]$ ssh example.com ssh: Could not resolve hostname example.com: Name or service not known
Verify the result of name resolution for
example.com.[student@server1 ~]$ getent hosts example.com [student@server1 ~]$
Verify the order that name services are used.
[student@server1 ~]$ grep ^hosts: /etc/nsswitch.conf hosts: files dns
Since files are used first, verify the contents of
/etc/hosts.[student@server1 ~]$ grep [[:space:]]example.com /etc/hosts [student@server1 ~]$
Since no hosts file entry exist for
example.com, verify the contents of/etc/resolv.conf; you should see that an incorrect nameserver IP is the cause of the name resolution failure.[student@server1 ~]$ grep ^nameserver /etc/resolv.conf nameserver 192.168.0.255
[student@server1 ~]$ dig @192.168.0.255 A example.com ; <<>> DiG 9.9.4-RedHat-9.9.4-14.el7 <<>> @192.168.0.255 A example.com ; (1 server found) ;; global options: +cmd ;; connection timed out; no servers could be reached
As
root, fix the error in/etc/resolv.confand verify that this resolves the name resolution issue.Because the
nameserverentry populated by DHCP was manually modified, asroot, force a refresh of the data from DHCP and validate that the entry is fixed.[student@server1 ~]$ sudo systemctl restart NetworkManager
[student@server1 ~]$ grep ^nameserver /etc/resolv.conf nameserver 192.168.0.254
Verify the results of name resolution for
example.com.[student@server1 ~]$ getent hosts example.com 192.168.0.254 example.com
[student@server1 ~]$ dig A example.com ; <<>> DiG 9.9.4-RedHat-9.9.4-14.el7 <<>> example.com ;; global options: +cmd ;; Got answer: ;; -->>HEADER<<-- opcode: QUERY, status: NOERROR, id: 36048 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 2 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 4096 ;; QUESTION SECTION: ;example.com. IN A ;; ANSWER SECTION: example.com. 86400 IN A 192.168.0.254 ;; AUTHORITY SECTION: example.com. 86400 IN NS classroom.example.com. ;; ADDITIONAL SECTION: classroom.example.com. 86400 IN A 192.168.0.254 ;; Query time: 1 msec ;; SERVER: 192.168.0.254#53(192.168.0.254) ;; WHEN: Thu May 15 07:28:35 EDT 2014 ;; MSG SIZE rcvd: 96
Verify that SSH connection to
example.comfromserver1.example.comnow succeeds.[student@server1 ~]$ ssh example.com The authenticity of host 'example.com (192.168.0.254)' can't be established. ECDSA key fingerprint is 12:b3:c8:3e:6b:d2:9f:43:67:a5:f2:2a:f0:7c:2f:b6. Are you sure you want to continue connecting (yes/no)?
3. Manage DNS for Servers
In this lab, you use DNS troubleshooting techniques and knowledge of unbound configuration to resolve DNS issues with a misconfigured unbound caching nameserver.
To improve DNS performance and security, a fellow system administrator has recently configured a secure caching nameserver running the unbound DNS server on server1.example.com to serve your local subnet, 192.168.0.0/24.
The caching nameserver uses DNS server 192.168.0.254 for name resolution. The administrator released the caching nameserver for use just prior to leaving for a week-long vacation.
Soon after your colleague leaves, you receive reports of DNS issues from users trying to use the newly configured caching nameserver for the first time. One user provides a specific example and reports that name resolution for example.com fails.
You need to troubleshoot and correct the unbound
misconfiguration that is causing this issue.
Reset your
server1.example.comsystem.Log in to and set up your
server1.example.comsystem.[student@server1 -]$ wget -O - http://instructor.example.com/pub/server1-unbound.sh | bash
On
desktop1.example.com, replicate the reported issue to determine the nature and scope of the problem.From
desktop1.example.com, issue a query for the address ofexample.comto the caching nameserver onserver1.example.com.[student@desktop1 -]$ dig @server1.example.com A example.com ; <<>> DiG 9.9.4-RedHat-9.9.4-14.el7 <<>> @server1.example.com example.com ; (1 server found) ;; global options: +cmd ;; connection timed out; no servers could be reached
Verify the operation of the caching nameserver on
server1.example.comby issuing queries to it locally fromserver1.example.com.Issue the query to the
localhostinterface. The query succeeds with no errors.[student@server1 -]$ dig @localhost A example.com ; <<>> DiG 9.9.4-RedHat-9.9.4-14.el7 <<>> @localhost A example.com ; (2 servers found) ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 64095 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 4096 ;; QUESTION SECTION: ;example.com. IN A ;; ANSWER SECTION: example.com. 84526 IN A 192.168.0.254 ;; Query time: 0 msec ;; SERVER: ::1#53(::1) ;; WHEN: Wed May 21 05:12:00 EDT 2014 ;; MSG SIZE rcvd: 56
Issue the query to the
192.168.0.101interface. No response is received and the query times out.[student@server1 -]$ dig @192.168.0.101 A example.com ; <<>> DiG 9.9.4-RedHat-9.9.4-14.el7 <<>> @192.168.0.101 A example.com ; (1 server found) ;; global options: +cmd ;; connection timed out; no servers could be reached
Determine which interfaces
unboundis listening on. You should discover that it’s only listening on thelocalhostinterface.[student@server1 -]$ sudo ss -tulpn | grep -w 53 tcp UNCONN 0 0 127.0.0.1:53 *:* users:"unbound",2192,5 tcp UNCONN 0 0 ::1:53 :::* users:"unbound",2192,3 tcp LISTEN 0 5 127.0.0.1:53 *:* users:"unbound",2192,6 tcp LISTEN 0 5 ::1:53 :::* users:"unbound",2192,4
Fix the issue discovered and verify that it resolved the name resolution issue.
Configure
unboundto listen on all interfaces by adding the following entry in/etc/unbound/unbound.conf.interface: 0.0.0.0
Check the configuration for syntax errors.
[student@server1 -]$ sudo unbound-checkconf unbound-checkconf: no errors in /etc/unbound/unbound.conf
Restart the service for the changes to take place.
[student@server1 -]$ sudo systemctl restart unbound
On
server1.example.com, rerun the query to the192.168.0.101interface. You should now receive a response, but with a status ofREFUSED.[student@server1 -]$ dig @192.168.0.101 A example.com ; <<>> DiG 9.9.4-RedHat-9.9.4-14.el7 <<>> @192.168.0.101 A example.com ; (1 server found) ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: REFUSED, id: 50719 ;; flags: qr rd ad; QUERY: 0, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0 ;; WARNING: recursion requested but not available ;; Query time: 0 msec ;; SERVER: 192.168.0.101#53(192.168.0.101) ;; WHEN: Wed May 21 05:36:43 EDT 2014 ;; MSG SIZE rcvd: 12
While the DNS communication now works, the return code in the DNS response indicates that there may be another misconfiguration issue present. Verify the
unboundconfiguration onserver1.example.com.Since
REFUSEDstatus indicates a policy restriction, verify that the proper access policy is in place in/etc/unbound/unbound.conf. You should see that no access control has been granted for the subnet.[student@server1 -]$ sudo grep ^[[:space:]]*access-control /etc/unbound/unbound.conf
Fix the issue discovered and verify that it resolved the name resolution issue.
Grant the
192.168.0.0/24subnet access to the caching nameserver in/etc/unbound/unbound.conf.[student@server1 -]$ sudo grep ^[[:space:]]*access-control /etc/unbound/unbound.conf access-control: 192.168.0.0/24 allowCheck the configuration for syntax errors.
[student@server1 -]$ sudo unbound-checkconf unbound-checkconf: no errors in /etc/unbound/unbound.conf
Restart the service for the changes to take place.
[student@server1 -]$ sudo systemctl restart unbound
On
server1.example.com, rerun the previously failed query. It should now succeed.[student@server1 -]$ dig @192.168.0.101 A example.com ; <<>> DiG 9.9.4-RedHat-9.9.4-14.el7 <<>> @192.168.0.101 A example.com ; (1 server found) ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 25229 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 4096 ;; QUESTION SECTION: ;example.com. IN A ;; ANSWER SECTION: example.com. 86339 IN A 192.168.0.254 ;; Query time: 0 msec ;; SERVER: 192.168.0.101#53(192.168.0.101) ;; WHEN: Wed May 21 05:56:16 EDT 2014 ;; MSG SIZE rcvd: 56
On
desktop1.exampl.com, rerun the query toserver1.example.com. It should now succeed.[student@desktop1 -]$ dig @server1.example.com A example.com ; <<>> DiG 9.9.4-RedHat-9.9.4-14.el7 <<>> @server1.example.com A example.com ; (1 server found) ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 25229 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 4096 ;; QUESTION SECTION: ;example.com. IN A ;; ANSWER SECTION: example.com. 86339 IN A 192.168.0.254 ;; Query time: 0 msec ;; SERVER: 192.168.0.101#53(192.168.0.101) ;; WHEN: Wed May 21 05:56:16 EDT 2014 ;; MSG SIZE rcvd: 56